package com.demo.bean9001.controller.contact;


import com.demo.bean9001.service.contact.BranchCompanyService;
import com.demo.common.entity.BranchCompanyDTO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 分公司
 * 作者：张兴然
 * 分配任务：张改
 * 插入数据：贾冠博
 */
@RestController
public class BranchCompanyController {

    @Resource
    private BranchCompanyService branchCompanyService;

    /**
     * 分页数据
     * @param pagenum
     * @return
     */
    @GetMapping("branchCompany")
    public List<BranchCompanyDTO> selectBranchCompany(@RequestParam(value = "pagenum",defaultValue = "1")Integer pagenum){
        //分页展示数据
        List<BranchCompanyDTO> branchCompanies = branchCompanyService.selectCompanyNameAndAddress(pagenum,3);

        return branchCompanies;
    }
    /**
     * 全部数据
     */
    @GetMapping("branchCompanyAll")
    public List<BranchCompanyDTO> selectBranchCompanyAll(){
        List<BranchCompanyDTO> branchCompanies = branchCompanyService.selectCompanyNameAndAddress(0,0);
        return branchCompanies;
    }

    /**
     * 同过下拉显示多条数据
     * @param pageSize
     * @return
     */
    @GetMapping("branchCompanyBySize")
    public List<BranchCompanyDTO> selectBranchBySize(@RequestParam(value = "pageSize",defaultValue = "5")Integer pageSize){
        System.out.println("pageSize = " + pageSize);
        return branchCompanyService.selectCompanyNameAndAddressBySize(pageSize);
    }


}
